<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title>系统登录</title>
		<link rel="stylesheet" href="css/login.css">
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script src="./lib/layui/layui.js" charset="utf-8"></script>
	</head>
	<body class="login-bg">

		<div class="login">
			<div class="message">系统登录</div>
			<div id="darkbannerwrap"></div>
			<form method="post" class="layui-form">
				<input id="username" name="username" placeholder="用户名" type="text" lay-verify="required"
					class="layui-input">
				<hr class="hr15">
				<input id="password" name="password" lay-verify="required" placeholder="密码" type="password"
					class="layui-input">
				<hr class="hr15">
				<input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
				<hr class="hr20">
			</form>
		</div>
		<script src="js/base.js"></script>
		<script src="js/md5.js"></script>
		<script>
			layui.use(['form'],
				function() {
					$ = layui.jquery;
					var form = layui.form(),
						layer = layui.layer;

					//监听提交
					form.on('submit(login)',
						function(data) {
							//alert(1);
							/*console.log(data);*/
							let username = document.getElementById("username").value;
							let password = document.getElementById("password").value;

							password = md5(md5(password + "neuedu.com").toUpperCase() + "java01").toUpperCase();

							let url = "http://localhost:8080/wuye/UserController/signIn";
							let method = "post";
							let json = {};
							json.username = username;
							json.password = password;
							rest(url, method, json, function(r) {
								if (r.code == 200) {
									let user = r.data;
									localStorage.setItem("id", user.id);
									localStorage.setItem("username", user.username);
									localStorage.setItem("password", user.password);
									localStorage.setItem("icon", user.icon);
									localStorage.setItem("telephone", user.telephone);
									localStorage.setItem("description", user.description);
									layer.alert("登录成功", {
										title: '点击确定进入后台'
									}, function() {
										location.href = "./index.html";
									});
								} else {
									layer.alert(r.msg, {
										title: '点击重新输入信息'
									}, function() {
										location.href = "./login.html";
									});
								}
							});
							return false;
						});

				});
		</script>


		<!-- 底部结束 -->

	</body>
</html>